home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / ChipCD 6.02.iso / macos / files / ModemScN.sit / Nokia GSM Analogue 14.4 RB next >
Text File  |  2001-04-10  |  7KB  |  441 lines

  1. !  Nokia GSM
  2. !
  3. !    Author:    Ross Barkman
  4. !
  5. !
  6. !    History:
  7. !        24 Jan 01    First release of base script
  8. !        26 Jan 01    Configured for standard GSM
  9. !        13 Feb 01    Configured for 14.4k
  10. !        10 Apr 01    Add +IFC=0,2 to overcome flow control problem
  11. !
  12. !  'mlts' resource info:
  13. !    byte 1 == 01 -> modem HAS built-in error correction protocols
  14. !    byte 2 == 01 -> modem HAS built-in data compression protocols
  15. !    byte 3 == 200 -> max number of chars in varstr 7
  16. !    byte 4 == 200 -> max number of chars in varstr 8
  17. !    byte 5 == 200 -> max number of chars in varstr 9
  18. !    
  19. @ORIGINATE
  20. @ANSWER
  21. !
  22. ! ---- Modem setup ----
  23. !
  24. @LABEL 1
  25. !
  26. ! Set serial port speed 115200, all interface signals off
  27. serreset 115200, 0, 8, 1
  28. hsreset 0 0 0 0 0 0
  29. settries 0
  30. !
  31. ! Check the phone is responding
  32. !
  33. matchclr
  34. matchstr 1 2 "OK\13\10"
  35. write "AT\13"
  36. matchread 30
  37. jump 101
  38. !
  39. ! Check the phone is a Nokia
  40. !
  41. @LABEL 2
  42. matchclr
  43. matchstr 1 3  "Nokia"
  44. write "AT+CGMI\13"
  45. matchread 60
  46. jump 109
  47. !
  48. @LABEL 3
  49. !
  50. ! Configure the phone
  51. !
  52. matchclr
  53. matchstr 1 5   "OK\13\10"
  54. matchstr 2 101 "ERROR\13\10"
  55. write "AT&FE0V1&D2&S0&C1S0=0+IFC=0,2\13"
  56. matchread 30
  57. inctries
  58. iftries 3 101
  59. jsr 7
  60. jump 3
  61. !
  62. @LABEL 5
  63. pause 20
  64. settries 0
  65. !
  66. @LABEL 6
  67. !
  68. ! Set additional options
  69. !
  70. matchclr
  71. matchstr 1 9   "OK\13\10"
  72. matchstr 2 108 "ERROR\13\10"
  73. write "AT+CBST=14,0,1\13"
  74. matchread 60
  75. inctries
  76. iftries 3 101
  77. jsr 7
  78. jump 6
  79. !
  80. @LABEL 7
  81. !
  82. ! Attempt to reset the phone
  83. !
  84. DTRClear
  85. pause 5
  86. DTRSet
  87. flush
  88. return
  89. !
  90. @LABEL 9
  91. !
  92. ! Setup complete
  93. !
  94. ifANSWER 32
  95. !
  96. !
  97. ! ---- Place a call ----
  98. !
  99. @LABEL 20
  100. !
  101. ! Display the full dialstring (Varstring 1)
  102. !
  103. note "Dialling ^1" 3
  104. !
  105. ! Varstrings 7, 8 and 9 may contain partial dialstrings
  106. !    if the number is longer than the phone's buffer
  107. !    (unlikely, but we allow for it)
  108. ifstr 8 27 " "
  109. ifstr 9 24 " "
  110. !
  111. !  Write dialstring in varstrings 7, 8 & 9
  112. matchclr
  113. matchstr 1 21 "OK\13\10"
  114. write "ATX5D^3^7;\13"
  115. matchread 400
  116. jump 101
  117. !
  118. @LABEL 21
  119. matchclr
  120. matchstr 1 22 "OK\13\10"
  121. write "ATX5D^3^8;\13"
  122. matchread 400
  123. jump 101
  124. !
  125. @LABEL 22
  126. write "ATX5D^3^9\13"
  127. jump 32
  128. !
  129. !
  130. @LABEL 24
  131. !  Write dialstring in varstrings 7 & 8
  132. matchclr
  133. matchstr 1 25 "OK\13\10"
  134. write "ATX5D^3^7;\13"
  135. matchread 400
  136. jump 101
  137. !
  138. @LABEL 25
  139. write "ATX5D^3^8\13"
  140. jump 32
  141. !
  142. @LABEL 27
  143. !  Write dialstring in varstring 7
  144. write "ATX5D^3^7\13"
  145. !
  146. !
  147. ! ---- Connect response ----
  148. !
  149. ! Parses successful connect responses in the following format:
  150. !   CARRIER
  151. !    +ER xxxx
  152. !    +DR yyyy
  153. !   CONNECT zzzzz
  154. !
  155. @LABEL 32
  156. matchclr
  157. matchstr  1 81  "RING\13\10"
  158. matchstr  2 102 "NO DIALTONE\13\10"
  159. matchstr  3 103 "NO CARRIER"
  160. matchstr  4 103 "ERROR\13\10"
  161. matchstr  5 104 "BUSY\13\10"
  162. matchstr  6 105 "NO ANSWER\13\10"
  163. matchstr  7 33  "CARRIER"
  164. matchstr  8 34  "CONNECT"
  165. matchstr  9 61  "+ER"
  166. matchstr 10 66  "+DR"
  167. matchread 700
  168. ifANSWER 32
  169. jump 105
  170. !
  171. !  CARRIER parsing
  172. !
  173. @LABEL 33
  174. note "Network carrier detected" 2
  175. jump 32
  176. !
  177. !  CONNECT parsing
  178. !
  179. @LABEL 34
  180. !
  181. !    2400 and 4800 have two entries each
  182. !    to distinguish them from 24000 and 48000
  183. !
  184. matchclr
  185. matchstr  1 40 "2400\13"
  186. matchstr  2 40 "2400/"
  187. matchstr  3 41 "4800\13"
  188. matchstr  4 41 "4800/"
  189. matchstr  5 42 "7200"
  190. matchstr  6 43 "9600"
  191. matchstr  7 44 "12000"
  192. matchstr  8 45 "14400"
  193. matchstr  9 46 "19200"
  194. matchstr 10 51 "28800"
  195. matchstr 11 52 "38400"
  196. matchstr 12 53 "43200"
  197. matchstr 13 54 "48000"
  198. matchstr 14 55 "56000"
  199. matchstr 15 56 "64000"
  200. matchread 10
  201. jump 59
  202. !
  203. ! -- Connection rates --
  204. !
  205. ! CommunicatingAt informs ARA of the link speed
  206. !
  207. @LABEL 40
  208. note "Communicating at 2400 bps." 2
  209. CommunicatingAt 2400
  210. jump 60
  211. !
  212. @LABEL 41
  213. note "Communicating at 4800 bps." 2
  214. CommunicatingAt 4800
  215. jump 60
  216. !
  217. @LABEL 42
  218. note "Communicating at 7200 bps." 2
  219. CommunicatingAt 7200
  220. jump 60
  221. !
  222. @LABEL 43
  223. note "Communicating at 9600 bps." 2
  224. CommunicatingAt 9600
  225. jump 60
  226. !
  227. @LABEL 44
  228. note "Communicating at 12400 bps." 2
  229. CommunicatingAt 12400
  230. jump 60
  231. !
  232. @LABEL 45
  233. note "Communicating at 14400 bps." 2
  234. CommunicatingAt 14400
  235. jump 60
  236. !
  237. @LABEL 46
  238. note "Communicating at 19200 bps." 2
  239. CommunicatingAt 19200
  240. jump 60
  241. !
  242. @LABEL 51
  243. note "Communicating at 28800 bps." 2
  244. CommunicatingAt 28800
  245. jump 60
  246. !
  247. @LABEL 52
  248. note "Communicating at 38400 bps." 2
  249. CommunicatingAt 38400
  250. jump 60
  251. !
  252. @LABEL 53
  253. note "Communicating at 43200 bps." 2
  254. CommunicatingAt 43200
  255. jump 60
  256. !
  257. @LABEL 54
  258. note "Communicating at 48000 bps." 2
  259. CommunicatingAt 48000
  260. jump 60
  261. !
  262. @LABEL 55
  263. note "Communicating at 56000 bps." 2
  264. CommunicatingAt 56000
  265. jump 60
  266. !
  267. @LABEL 56
  268. note "Communicating at 64000 bps." 2
  269. CommunicatingAt 64000
  270. jump 60
  271. !
  272. @LABEL 59
  273. note "Communicating at an unknown rate." 2
  274. !
  275. @LABEL 60
  276. jump 70
  277. !
  278. ! -- +ER (error correction reporting) parsing --
  279. !
  280. ! Userhook 2 informs ARA that a modem-to-modem error
  281. ! correcting protocol has been negotiated
  282. !
  283. @LABEL 61
  284. matchclr
  285. matchstr  1 63 "NONE"
  286. matchstr  2 62 "LAPM"
  287. matchstr  3 62 "ALT"
  288. matchstr  4 63 "\13"
  289. matchread 10
  290. jump 63
  291. !
  292. @LABEL 62
  293. note "Modem Reliable Link Established." 2
  294. userhook 2
  295. !
  296. @LABEL 63
  297. jump 32
  298. !
  299. ! -- +DR (data compression reporting) parsing --
  300. !
  301. ! Userhook 3 informs ARA that a modem-to-modem compression
  302. ! protocol has been negotiated
  303. !
  304. @LABEL 66
  305. matchclr
  306. matchstr  1 68 "NONE"
  307. matchstr  2 67 "V42B"
  308. matchstr  3 67 "MNP5"
  309. matchstr  4 68 "\13"
  310. matchread 10
  311. jump 68
  312. !
  313. @LABEL 67
  314. note "Modem Compression Established." 2
  315. userhook 3
  316. !
  317. @LABEL 68
  318. jump 32
  319. !
  320. !
  321. ! -- Normal exit after "CONNECT" --
  322. !
  323. !
  324. @LABEL 70
  325. !
  326. ! Turn CTS on, for hardware flow control
  327. !
  328. HSReset 0 1 0 0 0 0
  329. !
  330. ifANSWER 71
  331. pause 30
  332. !
  333. @LABEL 71
  334. exit 0
  335. !
  336. !
  337. ! ---- Answer calls ----
  338. !
  339. !    A RING result from the modem and in ANSWERING mode
  340. !    claims the serial port and answering the phone
  341. !
  342. @LABEL 81
  343. ifORIGINATE 32
  344. userhook 1
  345. note "Answering phone..." 2
  346. write "ATA\13"
  347. jump 32
  348. !
  349. !
  350. ! ---- Hang up and reset modem ----
  351. !
  352. @HANGUP
  353. @LABEL 90
  354. settries 0
  355. HSReset 0 0 0 0 0 0
  356. !
  357. @LABEL 92
  358. !
  359. !  Escape from data to command mode
  360. !
  361. matchclr
  362. matchstr 1 94 "OK\13\10"
  363. pause 11
  364. write "+++"
  365. matchread 20
  366. !
  367. @LABEL 94
  368. !
  369. ! Send hangup command
  370. !
  371. pause 10
  372. matchclr
  373. matchstr 1 98 "NO CARRIER\13\10"
  374. matchstr 2 98 "OK\13\10"
  375. matchstr 3 98 "ERROR\13\10"
  376. matchstr 4 98 "0\13\10"
  377. write "AT+CHUP\13"
  378. matchread 30
  379. ! If that fails, toggle DTR
  380. !
  381. DTRClear
  382. pause 5
  383. DTRSet
  384. flush
  385. !
  386. ! Try this three times only
  387. !
  388. inctries
  389. iftries 3 101
  390. jump 92
  391. !
  392. !
  393. @LABEL 98
  394. !
  395. ! Reset phone to default settings
  396. !
  397. pause 10
  398. matchclr
  399. matchstr 1 99 "OK\13\10"
  400. write "AT&F\13"
  401. matchread 30
  402. jump 101
  403. !
  404. @LABEL 99
  405. exit 0
  406. !
  407. ! ---- Error messages -----
  408. !
  409. ! Modem Not Responding
  410. @LABEL 101
  411. exit -6019
  412. !
  413. ! No Dial Tone
  414. @LABEL 102
  415. exit -6020
  416. !
  417. ! No Carrier or Error
  418. @LABEL 103
  419. exit -6021
  420. !
  421. ! Busy
  422. @LABEL 104
  423. exit -6022
  424. !
  425. ! No Answer
  426. @LABEL 105
  427. exit -6023
  428. !
  429. ! User Cancellation
  430. @LABEL 107
  431. exit -6008
  432. !
  433. @LABEL 108
  434. exit -6002 "The phone or network does not seem to support the speed or encoding type (e.g. V.110 or V.120) required for this script"
  435. !
  436. @LABEL 109
  437. exit -6002 "This script is only suitable for Nokia mobile phones"
  438.